<body>
<p>Load a bunch of videos.
<script>
var url = new URL(location);
var subresourceUrl = url.searchParams.get('url');
var numSubresources = parseInt(url.searchParams.get('numSubresources'), 10);

var numDone = 0;
function onVideoDone() {
  numDone++;
  if (numDone == numSubresources)
    parent.postMessage('loaded', '*');
}

for (var i = 0; i < numSubresources; i++) {
  var video  = document.createElement('video');
  video.src = subresourceUrl + "?" + i;
  video.onerror = onVideoDone;
  video.onload = onVideoDone;
  document.body.appendChild(video);
}
</script>
